package yrjdezu.abab.engineerpractice2.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yrjdezu.abab.engineerpractice2.common.result.Result;
import yrjdezu.abab.engineerpractice2.domain.dto.FoldersDTO;
import yrjdezu.abab.engineerpractice2.service.IFoldersService;

/**
 * <p>
 * 文件夹表 前端控制器
 * </p>
 *
 * @author lzh
 * @since 2025-05-18
 */
@RestController
@RequestMapping("/folders")
@Api(tags = "文件夹管理接口")
public class FoldersController {

    @Autowired
    private IFoldersService foldersService;

    /**
     * 新建文件夹
     */
    @PostMapping("/create")
    @ApiOperation("新增文件夹")
    @ResponseBody
    public Result<Void> createFolder(@RequestBody FoldersDTO requestParam) {
        foldersService.save(requestParam);
        return Result.success();
    }

    /**
     * 删除文件夹
     */
    @PostMapping("/delete/{id}")
    @ApiOperation("删除文件夹")
    @ResponseBody
    public Result<Void> deleteFolder(@PathVariable("id") Integer folderId) {
        foldersService.removeById(folderId);
        return Result.success();
    }
}
